<?php
require_once '../include/common.inc.php';
$query = "select count(*) as counter from userinfo where name = '$name'";
$result=$db->get_one($query);
$total = $result["counter"];
if ($total == 0)
{
	$query = "INSERT INTO userinfo SET 
		name = '$name',
		type = '1'";
	$db->query($query);
}

	$query = "select id from userinfo where name = '$name'";
	$result=$db->get_one($query);
	$userid = $result[id];
	
	$query = "select id from softinfo where code = '$code'";
	$result=$db->get_one($query);
	$softid = $result[id];
	
	$nowdate=date("m-d-Y H:i:s"); 
	$query = "INSERT INTO salesorder SET 
		userid = '$userid',
		softid = '$softid',
		packageid = '$packageid',
		ordertime = '$nowdate',
		isovertime = '0'";
	$db->query($query);
	echo "ok";
?>